<?php
	@$cmd = $_GET['cmd'];
	@$page = $_GET['page'];
	$home_active = "";
	$intro_active = "";
	$product_active = "";
	$contact_active = "";
	
	include_once('libs/htdu_core.php');
	include_once('libs/shopping_cart.php');
	session_start();
	$exec_mysql = new execute_mysql_query();
	$global = new global_function();
	$ITEM_PER_PAGE = 12;
	if(!isset($_SESSION['CART'])) $_SESSION['CART'] = cart::get_instance();
	$CART = $_SESSION['CART'];
	switch($cmd)
	{
		case 1:
		$home_active = 'class="active"';
		$TITLE = "Trang chủ";
		$NAVI  = "Trang chủ";
		$INCLUDE_PATH = 'subs/home.php';
		break;
		case 2:
		$intro_active = 'class="active"';
		$TITLE = "Giới thiệu";
		$NAVI  = "» Giới thiệu";
		$INCLUDE_PATH = 'subs/intro.php';
		break;
		case 3:
		$product_active = 'class="active"';
		$TITLE = "Sản phẩm";
		$NAVI  = "» Sản phẩm";
		$INCLUDE_PATH = 'subs/product.php';
		@$pcat = $_GET['pcat'];
		@$scat = $_GET['scat'];
		if($pcat != '')
		{
			$pcat = str_replace('/', '', $pcat);
			$pcat_name = $exec_mysql->execute("select name from category where id = $pcat", 1);
			$TITLE = $pcat_name;
			$NAVI  = '» <a href="san-pham.html">Sản phẩm</a> » '.$pcat_name;
		}
		if($scat != '')
		{
			$scat = str_replace('/', '', $scat);
			$scat_name = $exec_mysql->execute("select name from sub_category where id = $scat", 1);
			$TITLE = $scat_name;
			$NAVI  = '» <a href="san-pham.html">Sản phẩm</a> » <a href="san-pham/'.$global->remove_sign($pcat_name).'/'.$pcat.'.html">'.$pcat_name.'</a> » '.$scat_name;
		}
		break;
		case 31:
		$product_active = 'class="active"';
		$TITLE = "Sản phẩm";
		$NAVI  = "» Sản phẩm";
		$INCLUDE_PATH = 'subs/detail_product.php';
		@$pcat = $_GET['pcat'];
		@$scat = $_GET['scat'];
		@$pro_id = $_GET['pro_id'];
		if($pcat != '')
		{
			$pcat = str_replace('/', '', $pcat);
			$pcat_name = $exec_mysql->execute("select name from category where id = $pcat", 1);
			$TITLE = $pcat_name;
			$NAVI  = '» <a href="san-pham.html">Sản phẩm</a> » '.$pcat_name;
		}
		if($scat != '')
		{
			$scat = str_replace('/', '', $scat);
			$scat_name = $exec_mysql->execute("select name from sub_category where id = $scat", 1);
			$TITLE = $scat_name;
			$NAVI  = '» <a href="san-pham.html">Sản phẩm</a> » <a href="san-pham/'.$global->remove_sign($pcat_name).'/'.$pcat.'.html">'.$pcat_name.'</a> » '.$scat_name;
		}
		if($pro_id != '')
		{
			$pro_id = str_replace('/', '', $pro_id);
			$pcat_name = $exec_mysql->execute("select name from category where id = $pcat", 1);
			$scat_name = $exec_mysql->execute("select name from sub_category where id = $scat", 1);
			$pro_name = $exec_mysql->execute("select name from product where id = $pro_id", 1);
			$TITLE = $pro_name;
			$NAVI  = '» <a href="san-pham.html">Sản phẩm</a> » <a href="san-pham/'.$global->remove_sign($pcat_name).'/'.$pcat.'.html">'.$pcat_name.'</a> » 
				<a href="san-pham/'.$global->remove_sign($pcat_name).'/'.$global->remove_sign($scat_name).'/'.$pcat.'/'.$scat.'.html">'.$scat_name.'</a> » '.$pro_name;
		}
		break;
		case 4:
		$contact_active = 'class="active"';
		$TITLE = "Liên hệ";
		$NAVI  = "» Liên hệ";
		$INCLUDE_PATH = 'subs/contact.php';
		break;
		case 5:
		$TITLE = "Giỏ hàng";
		$NAVI  = "» Giỏ hàng";
		$INCLUDE_PATH = 'subs/cart.php';
		break;
		case 6:
		$TITLE = "Gởi đơn đặt hàng";
		$NAVI  = "» Gởi đơn đặt hàng";
		$INCLUDE_PATH = 'subs/send_order.php';
		break;
		case 7:
		$TITLE = "Kết quả đặt hàng";
		$NAVI  = "» Kết quả hàng";
		$INCLUDE_PATH = 'subs/result_order.php';
		break;
		default:
		$home_active = 'class="active"';
		$TITLE = "Trang chủ";
		$NAVI  = "Trang chủ";
		$INCLUDE_PATH = 'subs/home.php';
		break;
	}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <base href="http://127.0.0.1/dev/tranhtheu/" />
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <link rel="stylesheet" type="text/css" href="css/layout.css" />
        <link rel="stylesheet" type="text/css" href="css/control.css" />
        <link rel="stylesheet" href="css/nivo-slider.css" type="text/css" media="screen" />
        <script type="text/javascript" src="js/jquery-1.7.1.min.js"></script>
        <script src="js/jquery.nivo.slider.pack.js" type="text/javascript"></script>
        <script type="text/javascript" src="js/master.js"></script>
        <title><?php echo $TITLE; ?> - Tranh thêu Nam Phương</title>
    </head>
    
    <body>
    	<!--alert dialog-->
        <div class="over-lay" id="alert-window">
        	<div class="dialog-window">
            	<p class="dialog-title" id="alert-title">Title</p>
                <p class="dialog-content" id="alert-content">Message here</p>
                <span class="dialog-button dialog-ok" id="btn-alert-ok" onclick="hideAlert()">OK</span>
            </div>
        </div>
        <!--confirm dialog-->
        <div class="over-lay" id="confirm-window">
        	<div class="dialog-window">
            	<p class="dialog-title" id="confirm-title">Title</p>
                <p class="dialog-content" id="confirm-content">Message here</p>
                <span class="dialog-button confirm-ok" id="btn-confirm-ok">CÓ</span>
                <span class="dialog-button confirm-cancel" id="btn-confirm-cancal" onclick="hideConfirm()">KHÔNG</span>
            </div>
        </div>
        <!--confirm dialog-->
        <div class="over-lay" id="prompt-window">
        	<div class="dialog-window">
            	<p class="dialog-title" id="prompt-title">Title</p>
                <p class="dialog-content" id="prompt-content">Message here</p>
                <p style="padding:5px;"><input type="text" id="prompt-val" style="width:332px" /></p>
                <span class="dialog-button confirm-ok" id="btn-prompt-ok">OK</span>
                <span class="dialog-button confirm-cancel" id="btn-prompt-cancal" onclick="hidePrompt()">HỦY</span>
            </div>
        </div>
    	<!--Ho tro truc tuyen, hot-line e-mail, gio hang, dang ky, dang nhap, tim kiem-->
        <?php
        	$yahoo = $exec_mysql->execute("select val from extra where ref = 'yahoo'", 1);
			$email = $exec_mysql->execute("select val from extra where ref = 'email'", 1);
			$hot_line = $exec_mysql->execute("select val from extra where ref = 'hot_line'", 1);
			$footer = $exec_mysql->execute("select val from extra where ref = 'footer'", 1);
		?>
        <div class="top">
        	<span class="span-support">Hỗ trợ online: <?php echo '<a href="ymsgr:sendIM?'.$yahoo.'"><img src="http://opi.yahoo.com/online?u='.$yahoo.'&m=g&t=1"/></a>';?></span>
            <span class="span-hotline">Hot-line: <?php echo $hot_line; ?></span>
            <span class="span-email">E-mail: <?php echo $email; ?></span>
            <span class="span-shopping-card"><a href="gio-hang.html">Giỏ hàng(<span id="cart_qty"><?php echo $CART->get_num_product(); ?></span>)</a></span>
            <input type="text" class="textbox-search" id="txt-search"  value="Mã sản phẩm"/>
        </div>
        
        <!--logo, main menu-->
        <div class="logo-main-menu">
        	<div class="logo-main-menu-containt">
            	<a href="trang-chu.html"><img src="img/logo.png" class="logo" /></a>
                <div class="main-menu">
                	<ul>
                    	<li <?php echo $home_active; ?>><a href="trang-chu.html">Trang chủ</a></li>
                        <li <?php echo $intro_active; ?>><a href="gioi-thieu.html">Giới thiệu</a></li>
                        <li <?php echo $product_active; ?>><a href="san-pham.html">Sản phẩm</a></li>
                        <li <?php echo $contact_active; ?>><a href="lien-he.html">Liên hệ</a></li>
                    </ul>
                </div>
            </div>
        </div>
        
        <!--slide show-->
        <div class="slide-show">
        	<div class="slider-wrapper">
           	 	<div id="slider" class="nivoSlider">
                	 <?php
						foreach (glob("pics/*.jpg") as $filename)
						{
							print('<img src="'.$filename.'" />');
						}
					?>
                </div>
            </div>
        </div>
        
        <!--body containt-->
        <div class="body-contain">
            <!--category menu-->
            <div class="cat-menu">
            	<div class="cat-menu-title"><p>Danh mục sản phẩm</p></div>
                <ul class="parent">
				<?php
                	$cat = $exec_mysql->execute("select * from category", 0);
					while($row_cat = mysql_fetch_array($cat))
					{
						$id_cat = $row_cat['id'];
						$cat_name = $row_cat['name'];
						echo '<li class="parent"><a href="san-pham/'.$global->remove_sign($cat_name).'/'.$id_cat.'.html">&raquo; '.$cat_name.'</a>';
						$sub_cat = $exec_mysql->execute("select * from sub_category where id_parent = $id_cat", 0);
						echo '<ul class="child">';
						while($row_sub_cat = mysql_fetch_array($sub_cat))
						{
							$id_sub_cat = $row_sub_cat['id'];
							$act = "";
							$sub_cat_name = $row_sub_cat['name'];
							if(@$scat == $id_sub_cat)
								$act = "active";
							echo '<li class="child '.$act.'"><a href="san-pham/'.$global->remove_sign($cat_name).'/'.$global->remove_sign($sub_cat_name).'/'.$id_cat.'/'.$id_sub_cat.'.html">&bull; '.$sub_cat_name.'</a></li>';
						}
						echo '</ul>';
						echo '</li>';
					}
				?>
                </ul>
            </div>
            
            <!--containt page-->
            <div class="content-containt">
            	<div class="navigative"><p><?php echo $NAVI; ?></p></div>
                <div class="containt-sub-page"><?php include_once($INCLUDE_PATH);?></div>
            </div>
        </div>
        
        <!--footer: copyright, developer-->
        <div class="footer">
            <p><?php echo $footer; ?> - Phát triển bởi <a href="http://datmuiinfo.com">DKT Group</a></p>
        </div>
    </body>
</html>